package com.gopay.common.cps.dao.wallet.trans.impl;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.gopay.common.base.dao.impl.BaseDAOImpl;
import com.gopay.common.cps.dao.wallet.trans.WaScanCodePayDao;
import com.gopay.common.domain.dps.WaScanCodePay;

/**
 * 
 * @author tangyang
 * 20171206
 */
@Repository("waScanCodePayDao")
public class WaScanCodePayDaoImp extends BaseDAOImpl<WaScanCodePay,Serializable> implements WaScanCodePayDao {

	@Override
	public WaScanCodePay save(WaScanCodePay entity) {
		return super.save(entity);
	}
	@Override
	public void update(WaScanCodePay entity) {
		super.update(entity);
	}
	@Override
	public WaScanCodePay findByGopayOrderId(String gopayOrderId){
		String hql = "from WaScanCodePay w where w.gopayOrderId = :gopayOrderId ";
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("gopayOrderId", gopayOrderId);
		List<WaScanCodePay> waScanCodePayList = super.findByHql(hql, param);
		if(waScanCodePayList!=null &&waScanCodePayList.size()>0){
			return waScanCodePayList.get(0);
		}
		return null;
	}
	@Override
	public WaScanCodePay findByMerOrderId(String merOrderId, Date merTxnTm){
		String hql = "from WaScanCodePay w where w.merOrderId = :merOrderId and w.merTxnTm = :merTxnTm";
		Map<String, Object> param = new HashMap<String, Object>();
		param.put("merOrderId", merOrderId);
		param.put("merTxnTm", merTxnTm);
		List<WaScanCodePay> waScanCodePayList = super.findByHql(hql, param);
		if(waScanCodePayList!=null &&waScanCodePayList.size()>0){
			return waScanCodePayList.get(0);
		}
		return null;
	}
}
